using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class ItemPurReqInfo
    {
		#region Local Variable
		public enum Field
		{
			DTB,
			RequestRef,
			RequestDate,
			PreparedBy,
			ApprovedBy,
			CreatedBy,
			CreatedDate,
			ModifiedBy,
			ModifiedDate
		}
		private String _DTB;
		private String _RequestRef;
		private DateTime _RequestDate;
		private String _PreparedBy;
		private String _ApprovedBy;
		private String _CreatedBy;
		private DateTime _CreatedDate;
		private String _ModifiedBy;
		private DateTime _ModifiedDate;
		
		public String DTB{	get{ return _DTB;} set{_DTB = value;} }
		public String RequestRef{	get{ return _RequestRef;} set{_RequestRef = value;} }
		public DateTime RequestDate{	get{ return _RequestDate;} set{_RequestDate = value;} }
		public String PreparedBy{	get{ return _PreparedBy;} set{_PreparedBy = value;} }
		public String ApprovedBy{	get{ return _ApprovedBy;} set{_ApprovedBy = value;} }
		public String CreatedBy{	get{ return _CreatedBy;} set{_CreatedBy = value;} }
		public DateTime CreatedDate{	get{ return _CreatedDate;} set{_CreatedDate = value;} }
		public String ModifiedBy{	get{ return _ModifiedBy;} set{_ModifiedBy = value;} }
		public DateTime ModifiedDate{	get{ return _ModifiedDate;} set{_ModifiedDate = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public ItemPurReqInfo()
		{
			_DTB = "";
			_RequestRef = "";
            _RequestDate = DateTime.Now;
			_PreparedBy = "";
			_ApprovedBy = "";
			_CreatedBy = "";
			_CreatedDate = DateTime.Now;
			_ModifiedBy = "";
			_ModifiedDate = DateTime.Now;
		}
		
		public ItemPurReqInfo(
		String DTB,
		String RequestRef,
		DateTime RequestDate,
		String PreparedBy,
		String ApprovedBy,
		String CreatedBy,
		DateTime CreatedDate,
		String ModifiedBy,
		DateTime ModifiedDate
		)
		{
			_DTB = DTB;
			_RequestRef = RequestRef;
			_RequestDate = RequestDate;
			_PreparedBy = PreparedBy;
			_ApprovedBy = ApprovedBy;
			_CreatedBy = CreatedBy;
			_CreatedDate = CreatedDate;
			_ModifiedBy = ModifiedBy;
			_ModifiedDate = ModifiedDate;
		}
		public ItemPurReqInfo(DataRow dr)
		{
			if (dr != null)
			{
				_DTB = dr[Field.DTB.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.DTB.ToString()]);
				_RequestRef = dr[Field.RequestRef.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.RequestRef.ToString()]);
				_RequestDate = dr[Field.RequestDate.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.RequestDate.ToString()]);
				_PreparedBy = dr[Field.PreparedBy.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.PreparedBy.ToString()]);
				_ApprovedBy = dr[Field.ApprovedBy.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ApprovedBy.ToString()]);
				_CreatedBy = dr[Field.CreatedBy.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.CreatedBy.ToString()]);
				_CreatedDate = dr[Field.CreatedDate.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.CreatedDate.ToString()]);
				_ModifiedBy = dr[Field.ModifiedBy.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ModifiedBy.ToString()]);
				_ModifiedDate = dr[Field.ModifiedDate.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.ModifiedDate.ToString()]);
			}
		}
		public ItemPurReqInfo(DataRowView dr)
		{
			if (dr != null)
			{
				_DTB = dr[Field.DTB.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.DTB.ToString()]);
				_RequestRef = dr[Field.RequestRef.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.RequestRef.ToString()]);
				_RequestDate = dr[Field.RequestDate.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.RequestDate.ToString()]);
				_PreparedBy = dr[Field.PreparedBy.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.PreparedBy.ToString()]);
				_ApprovedBy = dr[Field.ApprovedBy.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ApprovedBy.ToString()]);
				_CreatedBy = dr[Field.CreatedBy.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.CreatedBy.ToString()]);
				_CreatedDate = dr[Field.CreatedDate.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.CreatedDate.ToString()]);
				_ModifiedBy = dr[Field.ModifiedBy.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ModifiedBy.ToString()]);
				_ModifiedDate = dr[Field.ModifiedDate.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.ModifiedDate.ToString()]);
			}
		}
		public ItemPurReqInfo(ItemPurReqInfo objEntr)
		{			
			_DTB = objEntr.DTB;			
			_RequestRef = objEntr.RequestRef;			
			_RequestDate = objEntr.RequestDate;			
			_PreparedBy = objEntr.PreparedBy;			
			_ApprovedBy = objEntr.ApprovedBy;			
			_CreatedBy = objEntr.CreatedBy;			
			_CreatedDate = objEntr.CreatedDate;			
			_ModifiedBy = objEntr.ModifiedBy;			
			_ModifiedDate = objEntr.ModifiedDate;			
		}
        #endregion Constructor
        
        #region InitTable
		public static DataTable ToDataTable()
		{
			DataTable dt = new DataTable("ItemPurReq");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.DTB.ToString(), typeof(String)),
				new DataColumn(Field.RequestRef.ToString(), typeof(String)),
				new DataColumn(Field.RequestDate.ToString(), typeof(DateTime)),
				new DataColumn(Field.PreparedBy.ToString(), typeof(String)),
				new DataColumn(Field.ApprovedBy.ToString(), typeof(String)),
				new DataColumn(Field.CreatedBy.ToString(), typeof(String)),
				new DataColumn(Field.CreatedDate.ToString(), typeof(DateTime)),
				new DataColumn(Field.ModifiedBy.ToString(), typeof(String)),
				new DataColumn(Field.ModifiedDate.ToString(), typeof(DateTime))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.DTB.ToString()] = _DTB;
			row[Field.RequestRef.ToString()] = _RequestRef;
			row[Field.RequestDate.ToString()] = _RequestDate;
			row[Field.PreparedBy.ToString()] = _PreparedBy;
			row[Field.ApprovedBy.ToString()] = _ApprovedBy;
			row[Field.CreatedBy.ToString()] = _CreatedBy;
			row[Field.CreatedDate.ToString()] = _CreatedDate;
			row[Field.ModifiedBy.ToString()] = _ModifiedBy;
			row[Field.ModifiedDate.ToString()] = _ModifiedDate;
			return row;
		}
        #endregion InitTable
    }
}
